﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace PortalWeb.Core.Entity
{
    public enum EnumFunctionType
    {
        [Description("系统功能")]
        SystemFunction = 1,

        [Description("外部功能")]
        ExternalFunction = 2,
        [Description("外部功能")]
        Directory = 0
    }

    /// <summary>
    /// 系统功能
    /// </summary>
    [Table("Functions", Schema = "dbo")]
    public class Function
    {
        [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }

        public int? ParentId { get; set; }

        /// <summary>
        /// 功能名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 排序
        /// </summary>
        public int Order { get; set; }

        /// <summary>
        /// 是否显示
        /// </summary>
        public bool IsShow { get; set; }

        /// <summary>
        /// 图标
        /// </summary>
        public string Icon { get; set; }

        /// <summary>
        /// 不通类型，访问方式不同
        /// </summary>
        public EnumFunctionType Type { get; set; }

        /// <summary>
        /// 执行地址
        /// </summary>
        public string ActionUrl { get; set; }

        /// <summary>
        /// 操作人
        /// </summary>
        public string Operator { get; set; }

        /// <summary>
        /// 操作时间
        /// </summary>
        public DateTime OperationTime { get; set; }

        /// <summary>
        /// 多对一
        /// </summary>
        public virtual ApplicationUser OperatorUser { get; set; }

        public virtual List<string> RolesString { get; set; }

        public virtual ICollection<ApplicationRole> Roles { get; set; }

        public virtual Function Parent { get; set; }

        public virtual ICollection<Function> Children { get; set; }
    }
}
